package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;

import java.util.Arrays;

/**
 * 两次水满制水超过1分钟,再次水满冲洗时间
 * 接收应答一致:
 * 1、设备读取该时间
 * 2、服务器下发指令修改该时间
 */
public class ReadOrModifyReWashTimeMessage extends ProtocolMessage {

    /** 读取或修改二次重新时间，单位秒 */
    private short seconds;

    public short getSeconds() {
        return seconds;
    }

    public void setSeconds(short seconds) {
        this.seconds = seconds;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeShort(this.seconds);
    }

    @Override
    public void onDeserialize() {
        this.seconds = this.byteArray.readShort();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ReadOrModifyReWashTimeMessage{");
        sb.append("seconds=").append(seconds);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
